package com.hudson.plugin.server.hibernateDB.internal.domain.entity;

import javax.persistence.*;
import java.util.Collection;

/**
 * Created by IntelliJ IDEA.
 * User: Richard
 * Date: 5/29/11
 * Time: 12:24 PM
 * To change this template use File | Settings | File Templates.
 */
@Table(name = "projects", catalog = "reportdb")
@Entity
public class ProjectsEntity {
    private int id;

    @Column(name = "id", nullable = false, insertable = true, updatable = true, length = 10, precision = 0)
    @Id
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    private String projectName;

    @Column(name = "project_name", nullable = true, insertable = true, updatable = true, length = 64, precision = 0)
    @Basic
    public String getProjectName() {
        return projectName;
    }

    public void setProjectName(String projectName) {
        this.projectName = projectName;
    }

    private String childProjects;

    @Column(name = "child_projects", nullable = true, insertable = true, updatable = true, length = 64, precision = 0)
    @Basic
    public String getChildProjects() {
        return childProjects;
    }

    public void setChildProjects(String childProjects) {
        this.childProjects = childProjects;
    }

    private String parentProjects;

    @Column(name = "parent_projects", nullable = true, insertable = true, updatable = true, length = 64, precision = 0)
    @Basic
    public String getParentProjects() {
        return parentProjects;
    }

    public void setParentProjects(String parentProjects) {
        this.parentProjects = parentProjects;
    }

    private String type;

    @Column(name = "type", nullable = true, insertable = true, updatable = true, length = 32, precision = 0)
    @Basic
    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    private String url;

    @Column(name = "url", nullable = true, insertable = true, updatable = true, length = 256, precision = 0)
    @Basic
    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ProjectsEntity that = (ProjectsEntity) o;

        if (id != that.id) return false;
        if (childProjects != null ? !childProjects.equals(that.childProjects) : that.childProjects != null)
            return false;
        if (parentProjects != null ? !parentProjects.equals(that.parentProjects) : that.parentProjects != null)
            return false;
        if (projectName != null ? !projectName.equals(that.projectName) : that.projectName != null) return false;
        if (type != null ? !type.equals(that.type) : that.type != null) return false;
        if (url != null ? !url.equals(that.url) : that.url != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id;
        result = 31 * result + (projectName != null ? projectName.hashCode() : 0);
        result = 31 * result + (childProjects != null ? childProjects.hashCode() : 0);
        result = 31 * result + (parentProjects != null ? parentProjects.hashCode() : 0);
        result = 31 * result + (type != null ? type.hashCode() : 0);
        result = 31 * result + (url != null ? url.hashCode() : 0);
        return result;
    }

    private Collection<BuildsEntity> buildsesById;

    @OneToMany(mappedBy = "projectsByProjectId")
    public Collection<BuildsEntity> getBuildsesById() {
        return buildsesById;
    }

    public void setBuildsesById(Collection<BuildsEntity> buildsesById) {
        this.buildsesById = buildsesById;
    }

    private HudsonsEntity hudsonsByHudsonId;

    @ManyToOne
    public
    @JoinColumn(name = "hudson_id", referencedColumnName = "id")
    HudsonsEntity getHudsonsByHudsonId() {
        return hudsonsByHudsonId;
    }

    public void setHudsonsByHudsonId(HudsonsEntity hudsonsByHudsonId) {
        this.hudsonsByHudsonId = hudsonsByHudsonId;
    }

    private ViewsEntity viewsByViewId;

    @ManyToOne
    public
    @JoinColumn(name = "view_id", referencedColumnName = "id")
    ViewsEntity getViewsByViewId() {
        return viewsByViewId;
    }

    public void setViewsByViewId(ViewsEntity viewsByViewId) {
        this.viewsByViewId = viewsByViewId;
    }

    private Collection<PromotionsEntity> promotionsesById;

    @OneToMany(mappedBy = "projectsByProjectId")
    public Collection<PromotionsEntity> getPromotionsesById() {
        return promotionsesById;
    }

    public void setPromotionsesById(Collection<PromotionsEntity> promotionsesById) {
        this.promotionsesById = promotionsesById;
    }
}
